<?php 
$cs=Yii::app()->clientScript;
$cs->registerScript('truck_appointment_dialog_view',<<<END
$(document).bind('keydown',function(e){if(e.keyCode==27){parent.$.modal.close();}});
$("a[href=#]").click(function(){
	\$parent=$(window.parent.document);
	\$parent.find("#Truck_appointment_truck_plate_no").val($(this).text()).removeClass('error').next('span').remove();
	\$parent.find("#Truck_appointment_fk_truck_id").val($(this).attr('class'));
	\$parent.find("#Truck_appointment_driver1_name").val($(this).attr('driver_name')).removeClass('error').next('span').remove();
	\$parent.find("#Truck_appointment_fk_driver1_id").val($(this).attr('fk_driver_id'));
	\$parent.find("#Truck_appointment_driver1_mobile").val($(this).attr('driver_mobile')).removeClass('error').next('span').remove();
	\$parent.find("#truck_type").val($(this).attr('type'));
	\$parent.find("#truck_type_id").val($(this).attr('fk_type_id'));
	if($(this).attr('board_plate_no')!=''){//如果主车有默认尾板,将默认尾板编号、车型写入页面
		\$parent.find("#Truck_appointment_board_plate_no").val($(this).attr('board_plate_no')).removeClass('error').next('span').remove();
		\$parent.find("#Truck_appointment_fk_board_id").val($(this).attr('board_id'));
		\$parent.find("#Truck_appointment_type").val($(this).attr('board_type')).removeClass('error').next('span').remove();
		\$parent.find("#Truck_appointment_fk_type_id").val($(this).attr('board_fk_type_id'));
	}
	if(\$parent.find("#Truck_appointment_board_plate_no").val()==''){//如果页面没有输入尾板编号，将车头车型写入页面
		\$parent.find("#Truck_appointment_type").val($(this).attr('type')).removeClass('error').next('span').remove();
		\$parent.find("#Truck_appointment_fk_type_id").val($(this).attr('fk_type_id'));
	}	
	parent.$.modal.close();
	return false;
});
END
)
?>
<?php echo CHtml::beginForm(array($this->action->id));?>
<div style="padding-bottom:10px">
	车牌号：<input type="text" name="keys[trucks.plate_no]" size="7" value="<?php echo isset($_GET['keys']['trucks.plate_no'])?$_GET['keys']['trucks.plate_no']:'';?>"/>&nbsp;&nbsp;
	模糊查询：<input type="radio" name="keys[blur]" value="1" checked/>是  
	<input type="radio" name="keys[blur]" value="0" <?php echo isset($_GET['keys']['blur'])&&$_GET['keys']['blur']==0?'checked':'';?>/>否&nbsp;&nbsp;
	<input type="submit" value="搜索"/>
</div>
<?php echo CHtml::endForm();?>
<table class="dataGrid" width=80%>
  <tbody>
  	<tr>
<?php foreach($models as $n=>$model): ?>
	<?php if($n>1&&$n%4==0) echo '</tr><tr>';?>
    <td><?php echo CHtml::link($model->plate_no,'#',array(
		'class'=>$model->id,
		'driver_name'=>$model->major_driver_name,
		'fk_driver_id'=>$model->fk_driver_id,
		'driver_mobile'=>$model->manufacturer,
    	'type'=>$model->type,
    	'fk_type_id'=>$model->fk_type_id,
    	'board_plate_no'=>$model->board_plate_no,
    	'board_id'=>$model->board_id,
    	'board_type'=>$model->board_type,
    	'board_fk_type_id'=>$model->board_fk_type_id,
    	)); ?></td>
<?php endforeach; ?>
	</tr>
  </tbody>
</table>
<br/>
<?php $this->widget('CLinkPager',array('pages'=>$pages,'maxButtonCount'=>Yii::app()->params['dialog'][$this->action->id]['maxButtonCount'])); ?>